package com.dynamicthreadpool.strategy;

import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * AbortPolicy拒绝策略实现
 * 当任务无法被执行时，抛出RejectedExecutionException
 */
public class AbortPolicy implements RejectStrategy {

    @Override
    public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
        throw new RejectedExecutionException("Task " + r.toString() + 
                " rejected from " + executor.toString());
    }

    @Override
    public String getPolicyName() {
        return "abort";
    }
}
